var t = getApp();

Page({
    data: {
        tabsIndex: 0,
        circleId: 0,
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1
    },
    onLoad: function(t) {
        this.data.circleId = t.circleId, this.getListData();
    },
    onReady: function() {},
    setTabsIndex: function(t) {
        var a = t.currentTarget.dataset.index;
        this.setData({
            tabsIndex: a,
            networkLoading: !1
        }), this.getListData();
    },
    initData: function() {
        this.setData({
            page: 1,
            total_page: 0,
            isLoadMore: !0,
            networkLoading: !1
        });
    },
    getListData: function() {
        var a = this;
        this.initData();
        var e = t.getNetAddresss("plugin.circle.frontend.circle-member.get-circle-memberList"), i = this.data.tabsIndex, r = {
            circle_id: this.data.circleId
        };
        0 == i ? r.is_review = 0 : 1 == i && (e = t.getNetAddresss("plugin.circle.frontend.circle-invitation.review-invitation-list")), 
        t._postNetWork({
            url: e,
            data: r,
            success: function(e) {
                var i = e.data;
                if (1 != i.result) return t.tips(i.msg);
                a.data.total_page = i.data.last_page, a.data.total_page || (a.data.total_page = 0), 
                a.setData({
                    listData: i.data.data,
                    networkLoading: !0
                });
            }
        });
    },
    _getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var e = t.getNetAddresss("plugin.circle.frontend.circle-member.get-circle-memberList"), i = this.data.tabsIndex, r = {
                circle_id: this.data.circleId,
                page: this.data.page
            };
            0 == i ? r.is_review = 0 : 1 == i && (e = t.getNetAddresss("plugin.circle.frontend.circle-invitation.review-invitation-list")), 
            t._postNetWork({
                url: e,
                data: r,
                success: function(t) {
                    var e = t.data;
                    if (a.data.isLoadMore = !0, 1 === e.result) {
                        var i = a.data.listData.concat(e.data.data);
                        a.setData({
                            listData: i
                        });
                    } else a.data.page = a.data.page - 1, a.data.isLoadMore = !1;
                }
            });
        }
    },
    memberReview: function(a) {
        var e = this, i = a.currentTarget.dataset.review, r = a.currentTarget.dataset.id, s = a.currentTarget.dataset.index, n = t.getNetAddresss("plugin.circle.frontend.circle-member.review");
        t._postNetWork({
            url: n,
            data: {
                circle_id: this.data.circleId,
                review: i,
                circle_member_id: r
            },
            success: function(a) {
                var i = a.data;
                if (t.tips(i.msg), 1 == i.result) {
                    var r = e.data.listData;
                    r.splice(s, 1), e.setData({
                        listData: r
                    });
                }
            }
        });
    },
    invitationReview: function(a) {
        var e = this, i = a.currentTarget.dataset.review, r = a.currentTarget.dataset.id, s = a.currentTarget.dataset.index, n = t.getNetAddresss("plugin.circle.frontend.circle-invitation.review");
        t._postNetWork({
            url: n,
            data: {
                circle_id: this.data.circleId,
                review: i,
                invitation_id: r
            },
            success: function(a) {
                var i = a.data;
                if (t.tips(i.msg), 1 == i.result) {
                    var r = e.data.listData;
                    r.splice(s, 1), e.setData({
                        listData: r
                    });
                    try {
                        var n = getCurrentPages();
                        n[n.length - 3].updateView();
                    } catch (t) {
                        console.log(t);
                    }
                }
            }
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    onShareTimeline: function() {}
});